home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / NewsTicker.sit / NewsTicker / source code / Internet Code / Subwoofer.h < prev    next >
Text File  |  1997-06-18  |  9KB  |  261 lines

  1. /*
  2.     File:        Subwoofer.h
  3.  
  4.     Contains:    <contents>
  5.  
  6.     Written by:    Frederic Artru
  7.  
  8.         Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  9.  
  10.      You may incorporate this sample code into your applications without
  11.     restriction, though the sample code has been provided "AS IS" and the
  12.     responsibility for its operation is 100% yours.  However, what you are
  13.     not permitted to do is to redistribute the source as "DSC Sample Code"
  14.     after having made changes. If you're going to re-distribute the source,
  15.     we require that you make it clear in the source that the code was
  16.     descended from Apple Sample Code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.  
  20.         <24>     3/13/97    FA      no stuffit error. Adding kURLInvalidCallError
  21.         <23>     3/12/97    FA      adding periodic event
  22.         <22>     3/11/97    FA      typo in errors
  23.         <21>     3/10/97    FA      States aren't flags anymore
  24.         <20>      3/7/97    FA      adding kURLResourceFoundStateFlag and kURLResourceFoundEvent.
  25.                                     Removing URLIsValid. Removing BuffersAreLow event and state.
  26.         <19>      3/7/97    FA      adding kURLResourceNotFoundError
  27.         <18>      3/5/97    FA      adding kURLFileEmptyError
  28.         <17>      3/4/97    FA      adding kURLUserCancelledError
  29.         <16>      3/3/97    FA      Error in URLGetError
  30.         <15>     2/27/97    FA      API changes for post processing
  31.         <14>     2/26/97    FA      states are flags
  32.         <13>     2/26/97    FA      new properties and flag change
  33.         <12>     2/20/97    FA      making more generic
  34.         <11>     2/20/97    FA      URLGetError now returns URL error as a parameter. changed some
  35.                                     types. const char* defined as extern.
  36.         <10>     2/17/97    FA      removing URLSupportsScheme
  37.          <9>     2/12/97    FA      wrong error code base
  38.          <8>     2/12/97    FA      New changes to API
  39.          <7>      2/7/97    FA      More implementation
  40.          <6>     1/29/97    FA      Nee API changes
  41.          <5>     1/24/97    FA      Updated after new comments to API design.
  42.          <4>     1/23/97    FA      Incorporated Nick Kledzik's comments.
  43.          <3>     1/21/97    FA      Added new calls and properties.
  44.          <2>     1/17/97    FA      Added API
  45.          <1>     1/15/97    FA      first checked in
  46. */
  47.  
  48. #ifndef __SUBWOOFER__
  49. #define __SUBWOOFER__
  50.  
  51. #include <Types.h>
  52. #include <Files.h>
  53.  
  54. #ifdef __cplusplus
  55. extern "C" {
  56. #endif
  57.  
  58. //                                    ERRORS
  59. enum
  60. {
  61.     kURLSubwooferErrorCodeBase                = -30770, // ••• lower limit is -30789
  62.     kURLNoErr                                = noErr,
  63.     
  64.     kURLInvalidURLReferenceError            = kURLSubwooferErrorCodeBase - 0,
  65.     kURLInvalidParameterError                = kURLSubwooferErrorCodeBase - 1,
  66.     kURLProgressAlreadyDisplayedError        = kURLSubwooferErrorCodeBase - 2,
  67.     kURLFileExistsError                        = kURLSubwooferErrorCodeBase - 3,
  68.     kURLInvalidURLError                        = kURLSubwooferErrorCodeBase - 4,
  69.     kURLUnsupportedSchemeError                = kURLSubwooferErrorCodeBase - 5,
  70.     kURLServerBusyError                        = kURLSubwooferErrorCodeBase - 6,
  71.     kURLAuthenticationError                    = kURLSubwooferErrorCodeBase - 7,
  72.     kURLUnkownPropertyError                    = kURLSubwooferErrorCodeBase - 8,
  73.     kURLPropertyBufferToSmallError            = kURLSubwooferErrorCodeBase - 9,
  74.     kURLUnsetablePropertyError                = kURLSubwooferErrorCodeBase - 10,
  75.     kURLInvalidCallError                    = kURLSubwooferErrorCodeBase - 11,
  76.     kURLNoInternetConfigError                = kURLSubwooferErrorCodeBase - 12,
  77.     kURLUserCancelledError                    = kURLSubwooferErrorCodeBase - 13,
  78.     kURLFileEmptyError                        = kURLSubwooferErrorCodeBase - 14,
  79.     kURLResourceNotFoundError                = kURLSubwooferErrorCodeBase - 15
  80. };
  81.  
  82. //                                             TYPES
  83.  
  84. typedef struct OpaqueURLReference* URLReference;
  85.  
  86. // download flags
  87. typedef UInt32 URLOpenFlags;
  88. enum
  89. {
  90.     kURLReplaceExistingFileFlag                = 0x00000001,
  91.     kURLExpandFileFlag                        = 0x00000002,
  92.     kURLDisplayProgressFlag                    = 0x00000004,
  93.     kURLDisplayAuthFlag                        = 0x00000008
  94. };
  95.  
  96. // state flags
  97. typedef UInt32 URLState;
  98. enum
  99. {
  100.     kURLNullState                            = 0,
  101.     kURLInitiatingState                        = 1,
  102.     kURLLookingUpHostState                    = 2,    // NOT IN EXT HEADER
  103.     kURLConnectingState                        = 3,    // NOT IN EXT HEADER
  104.     kURLResourceFoundState                    = 4,    
  105.     kURLDownloadingState                    = 5,
  106.     kURLDataAvailableState                    = 0x10 + kURLDownloadingState,
  107.     kURLDownloadCompleteState                = 6,
  108.     kURLErrorOccurredState                    = 7,
  109.     kURLAbortingState                        = 8,
  110.     kURLCompletedState                        = 9
  111. };
  112.  
  113. // events
  114. typedef UInt32 URLEvent;
  115. enum
  116. {
  117.     kURLInitiatedEvent                        = kURLInitiatingState,
  118.     kURLResourceFoundEvent                    = kURLResourceFoundState,
  119.     kURLDownloadingEvent                    = kURLDownloadingState,
  120.     kURLAbortInitiatedEvent                    = kURLAbortingState,
  121.     kURLCompletedEvent                        = kURLCompletedState,
  122.     kURLErrorOccurredEvent                    = kURLErrorOccurredState,
  123.  
  124.     kURLDataAvailableEvent                    = kURLDataAvailableState,
  125.     kURLDownloadCompleteEvent                = kURLDownloadCompleteState,
  126.     
  127.     kURLPercentEvent                        = 30,
  128.     kURLPeriodicEvent                        = 31,
  129.     kURLPropertyChangedEvent                = 32    
  130. };
  131.  
  132. // event flags
  133. typedef UInt32 URLEventFlags;
  134. enum
  135. {
  136.     kURLinitiatedEventFlag                    = 1 << (kURLInitiatedEvent - 1),
  137.     kURLResourceFoundEventFlag                = 1 << (kURLResourceFoundEvent - 1),
  138.     kURLDownloadingFlag                        = 1 << (kURLDownloadingEvent - 1),
  139.     kURLAbortInitiatedFlag                    = 1 << (kURLAbortInitiatedEvent - 1),
  140.     kURLCompletedEventFlag                    = 1 << (kURLCompletedEvent - 1),
  141.     kURLErrorOccurredEventFlag                = 1 << (kURLErrorOccurredEvent - 1),
  142.  
  143.     kURLDataAvailableEventFlag                = 1 << (kURLDataAvailableEvent - 1),
  144.     kURLDownloadCompleteEventFlag            = 1 << (kURLDownloadCompleteEvent - 1),
  145.  
  146.     kURLPercentEventFlag                    = 1 << (kURLPercentEvent - 1),
  147.     kURLPeriodicEventFlag                    = 1 << (kURLPeriodicEvent - 1),
  148.     kURLPropertyChangedEventFlag            = 1 << (kURLPropertyChangedEvent - 1),
  149.     
  150.     kURLAllBufferEventsFlag                    = kURLDataAvailableEventFlag
  151.                                             + kURLDownloadCompleteEventFlag,
  152.     kURLAllNonBufferEventsFlag                = kURLinitiatedEventFlag
  153.                                             + kURLDownloadingFlag
  154.                                             + kURLAbortInitiatedFlag
  155.                                             + kURLCompletedEventFlag
  156.                                             + kURLErrorOccurredEventFlag
  157.                                             + kURLPercentEventFlag
  158.                                             + kURLPeriodicEventFlag
  159.                                             + kURLPropertyChangedEventFlag,
  160.     kURLAllEventsFlag                        = kURLAllBufferEventsFlag
  161.                                             + kURLAllNonBufferEventsFlag
  162.  
  163. };
  164.  
  165. // universal properties
  166. extern const char* kURLURL;
  167. extern const char* kURLResourceSize;
  168. extern const char* kURLLastModifiedTime;
  169. extern const char* kURLMIMEType;
  170. extern const char* kURLFileType;
  171. extern const char* kURLFileCreator;
  172. extern const char* kURLCharacterSet;
  173. extern const char* kURLResourceName;
  174. extern const char* kURLHost;
  175. extern const char* kURLAuthType;
  176. extern const char* kURLUserName;
  177. extern const char* kURLPassword;
  178. extern const char* kURLStatusString;
  179. extern const char* kURLIsSecure;
  180. extern const char* kURLCertificate;
  181.  
  182. // http and https properties
  183. extern const char* kURLHTTPRequestMethod;
  184. extern const char* kURLHTTPRequestHeader;
  185. extern const char* kURLHTTPRequestBody;
  186. extern const char* kURLHTTPRespHeader;
  187.  
  188. // authentication type flags
  189. enum
  190. {
  191.     kUserNameAndPaswordFlag                    = 0x00000001
  192. };
  193.  
  194. //                                    CALLBACK ROUTINES
  195.  
  196. typedef OSStatus (*URLNotifyProcPtr)(        UInt32 refCon,
  197.                                             URLReference urlRef,
  198.                                             URLEvent event,
  199.                                             const char* changed,
  200.                                             UInt32 downloadSize);
  201.  
  202. //                                    URLDOWNLOAD ROUTINE
  203.  
  204. extern OSStatus URLDownload(                const char* url,
  205.                                             FSSpec *destination,
  206.                                             URLOpenFlags openFlags);
  207.  
  208. //                                    URL REFERENCE ROUTINES
  209.  
  210. extern OSStatus URLNewReference(            const char* url,
  211.                                             URLReference *urlRef);
  212. extern OSStatus URLDisposeReference(        URLReference urlRef);
  213.  
  214. //                                    DOWNLOAD ROUTINES
  215.  
  216. extern OSStatus URLOpen(                    URLReference urlRef,
  217.                                             FSSpec* file,
  218.                                             URLOpenFlags openFlags,
  219.                                             URLNotifyProcPtr notifyProc,
  220.                                             URLEventFlags eventRegister,
  221.                                             UInt32 refCon);
  222. extern OSStatus URLAbort(                    URLReference urlRef);
  223. extern OSStatus URLGetDataAvailable(        URLReference urlRef,
  224.                                             Size *dataSize);
  225. extern OSStatus URLGetBuffer(                URLReference urlRef,
  226.                                             void** buffer,
  227.                                             Size *bufferSize);
  228. extern OSStatus URLReleaseBuffer(            URLReference urlRef,
  229.                                             void* buffer);
  230. extern OSStatus URLReadBuffer(                URLReference urlRef,
  231.                                             void* buffer,
  232.                                             Size requestedSize,
  233.                                             Size *actualSize);
  234.  
  235. //                                    URL INFORMATION ROUTINES
  236.  
  237. extern OSStatus URLGetProperty(                URLReference urlRef,
  238.                                             const char* property,
  239.                                             void* propertyBuffer,
  240.                                             Size bufferSize);
  241. extern OSStatus URLGetPropertySize(            URLReference urlRef,
  242.                                             const char* property,
  243.                                             Size *propertySize);
  244. extern OSStatus URLSetProperty(                URLReference urlRef,
  245.                                             const char* property,
  246.                                             void* propertyBuffer,
  247.                                             Size bufferSize);
  248.  
  249. //                                    UTILITY ROUTINES
  250.  
  251. extern OSStatus URLGetCurrentState(            URLReference urlRef,
  252.                                             URLState *state);
  253. extern OSStatus URLGetError(                URLReference urlRef,
  254.                                             OSStatus *urlError);
  255.  
  256. #ifdef __cplusplus
  257. }
  258. #endif
  259.  
  260. #endif /* __SUBWOOFER__ */
  261.